import Vue from 'vue';
import {encrypt} from "@/common/crypto";

const login = (data) => {
    return Vue.prototype.$u.post('user/login', encrypt(data));
}

export const code_login = (params) => {
    return Vue.prototype.$u.post('user/code-login', encrypt(params));
}
const register = (data) => {
    return Vue.prototype.$u.post('user/register', encrypt(data));
}
const info = (params) => {
    return Vue.prototype.$u.get('user/info', params);
};

const updateProfile = (data) => {
    return Vue.prototype.$u.put('user/profile', data);
}

const updateAccount = (data) => {
    return Vue.prototype.$u.put('user/updateAccount', encrypt(data));
}
const updatePwd = (data) => {
    return Vue.prototype.$u.put('user/updatePwd ', encrypt(data));
}

const forget_pwd = (params) => {
    return Vue.prototype.$u.post('user/forget_pwd', encrypt(params));
}

//注销
const cancelAccount = (params) => {
    return Vue.prototype.$u.post('user/cancel-account', encrypt(params));
}

// 取消注销
const regretCancelAccount = (params) => {
    return Vue.prototype.$u.post('user/regret-cancel', encrypt(params));
}
//保存邮箱
const updateEmail = (params) => {
    return Vue.prototype.$u.put('user/update-email', params);
}

export const bind_moible = (params) => {
    return Vue.prototype.$u.post('user/update-phone', encrypt(params));
}

export default {
    info,
    login,
    register,
    updateProfile,
    updateAccount,
    updatePwd,
    forget_pwd,
    cancelAccount,
    regretCancelAccount,
    updateEmail
}
